<template>
	<view>
		<view class="navi-bar">
			<view class="navi-back" @click="goBack">
				<
			</view>
			<view class="navi-title">
				问答
			</view>
		</view>
		<u-gap height="100" bgColor="#fff"></u-gap>
		<view class="ser-title">
			{{SerialContentList.title}}
		</view>
		<view class="ser-author">
			{{SerialContentList.json_content.simple_author[0]}}
		</view>
		<view class="ser-content" v-html="SerialContentList.json_content.content">
			{{SerialContentList.json_content.content}}
		</view>
		<view class="ser-editor">
			{{SerialContentList.json_content.editor}}
		</view>
		<view class="ser-copyright">
			{{SerialContentList.json_content.copyright}}
		</view>
		<view class="info-tag">
			{{SerialContentList.json_content.author.role}}
		</view>
		<view class="info-line"></view>
		<view class="ser-info"  @click="naviTo(SerialContentList.json_content.author.authors[0].id)">
			<view class="info-image">
				<image :src="SerialContentList.json_content.author.authors[0].avatar" mode=""></image>
			</view>
			<view class="info-intro">
				<view class="intro-name">
					{{SerialContentList.author_list[0].user_name}}
				</view>
				<view class="intro-brief">
					{{SerialContentList.author_list[0].summary}}
				</view>
			</view>
			<view class="info-btn">
				关注
			</view>
		</view>
		<view class="comment-tag">
			评论列表
		</view>
		<view class="info-line"></view>
		<view class="comment-list">
			<view class="comment-item" v-for="(c, i) in SerialCommentList" :key="c.id">
				<view class="comment-top">
					<view class="top-user">
						<view class="user-image">
							<image :src="c.user.web_url" mode="widthFix"></image>
						</view>
						<view class="user-name">
							{{c.user.user_name}}
						</view>
					</view>
					<view class="top-date">
						{{c.input_date}}
					</view>
				</view>
				<view class="comment-quote" v-show="c.quote !== ''">
					<text class="" v-if="c.touser !== null">
						{{c.touser.user_name}}
					</text>
					: {{c.quote}}
				</view>
				<view class="comment-text">
					{{c.content}}
				</view>
				<view class="comment-btn">
					<view class="btn-image">
						<image src="../../static/icons/dz.png" mode="heightFix"></image>
						{{c.praisenum}}
					</view>
					<image src="../../static/icons/pl.png" mode="heightFix"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		http
	} from '../../untils/http.js'
	
	const url = 'question/htmlcontent/'
	
	export default {
		data() {
			return {
				SerialContentList: [],
				SerialCommentList: []
			}
		},
		onLoad({
			id
		}) {
			this.getSerialContent(id)
			this.getSerialComment(id)
		},
		created() {
			
		},
		methods: {
			getSerialContent(id) {
				http(url + id).then(res => {
					this.SerialContentList = res.data
					console.log(this.SerialContentList);
				})
			},
			getSerialComment(id) {
				http('comment/praiseandtime/question/' + id + '/0').then(res => {
					this.SerialCommentList = res.data.data
					console.log(this.SerialCommentList);
				})
			},
			naviTo(id) {
				uni.navigateTo({
					url: '../AuthorDetails/AuthorDetails?id=' + id
				})
			},
			goBack() {
				// 返回上一级并刷新当前页面
				this.$router.go(-1)
			}
		}
	}
</script>

<style lang="scss">
	* {
		box-sizing: border-box;
	}
	
	.navi-bar {
		position: fixed;
		width: 750rpx;
		height: 100rpx;
		line-height: 100rpx;
		z-index: 1000;
		background-color: #fff;
		
		.navi-back {
			margin-left: 15px;
			float: left;
		}
		
		.navi-title {
			margin-right: 28px;
			text-align: center;
		}
	}
	
	.ser-title {
		padding: 5px 10px;
		font-size: 18px;
		font-weight: 700;
	}
	
	.ser-author {
		padding: 20px 10px;
		font-size: 10px;
	}
	
	.ser-content {
		padding: 10px;
		margin-bottom: 20px;
		font-size: 14px;
		
		/deep/ img {
			width: 100%;
		}
		
		/deep/ p {
			line-height: 24px;
			text-indent: 2em;
		}
	}
	
	.ser-editor {
		padding: 10px;
		font-size: 10px;
		color: #c1c1c1;
	}
	
	.ser-copyright {
		padding: 5px 10px;
		font-size: 10px;
		color: #c1c1c1;
	}
	
	.info-tag {
		padding: 10px;
		font-size: 14px;
	}
	
	.info-line {
		margin-left: 10px;
		width: 120rpx;
		border: 2px solid #000000;
	}
	
	.ser-info {
		padding: 10px;
		display: flex;
		
		.info-image {
			margin-right: 10px;
			flex: 1;
			
			image {
				width: 100%;
				height: 100%;
				border-radius: 999px;
			}
		}
		
		.info-intro {
			flex: 8;
			
			.intro-name {
				margin-bottom: 5px;
				font-size: 14px;
			}
			
			.intro-brief {
				width: 550rpx;
				font-size: 10px;
				color: #c1c1c1;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}
		
		.info-btn {
			margin: auto;
			padding: 3px 3px;
			flex: 1;
			font-size: 10px;
			text-align: center;
			border: 1px solid #5f5f5f;
		}
	}
	
	.comment-tag {
		padding: 10px;
		font-size: 14px;
	}
	
	.comment-list {
		width: 750rpx;
	}
	
	.comment-item {
		padding: 15px;
		width: 100%;
		border-bottom: 1px solid #c6c6c6;
	}
	
	.comment-top {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		
		.top-user {
			// flex: 2;
			display: flex;
			align-items: center;
			
			image {
				margin-right: 10px;
				width: 50rpx;
				height: 50rpx;
				border-radius: 999px;
			}
			
			.user-name {
				margin-bottom: 5px;
				font-size: 14px;
				color: #545454;
			}
		}
		
		.top-date {
			// flex: 2;
			font-size: 10px;
			color: #545454;
		}
	}
	
	.comment-quote {
		margin: 10px;
		padding: 8px;
		height: 70rpx;
		width: auto;
		font-size: 14px;
		border: 1px solid #bebebe;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	
	.comment-text {
		padding: 10px;
		font-size: 14px;
	}
	
	.comment-btn {
		display: flex;
		flex-direction: row-reverse;
		height: 50rpx;
		
		image {
			margin-right: 5px;
			// width: 100%;
			height: 100%;
		}
		
		.btn-image {
			margin-left: 20px;
			margin-right: 10px;
			display: flex;
			align-items: center;
			font-size: 12px;
			color: #8d8d8d;
		}
	}
</style>
